<template>
<div class='total'>
<div class="box">
  <el-table
    :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
    style="width: 100%"
    max-height="500"
    >
     <el-table-column
      prop="goods_id"
      label="货物编号"
      >
    </el-table-column>
      <el-table-column
      prop="name"
      label="客户"
      width="180">
    </el-table-column>
    <el-table-column
      prop="contact"
      label="联系方式">
      </el-table-column>
       <el-table-column
      prop="employees_name"
      label="入库员"
      width="180">
    </el-table-column>
       <el-table-column
      prop="warehouse_entry_time"
      label="入库日期">
      </el-table-column>
      <el-table-column label="操作" width="150">
          <template slot-scope="scope"> <el-button
             @click="see(scope.row)"
              type="text"
              size="small">
         查看
      </el-button>
       </template>
      </el-table-column>
  </el-table>

 <el-dialog title="核验入库信息" :visible.sync="dialogFormVisible" >
           <el-form :model="goods">
               <el-col :span="12">
             <el-form-item label="货物名称：" :label-width="formLabelWidth">
                <el-input v-model="goods.name" autocomplete="off" value="text" disabled="disabled" ></el-input>
              </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="货物种类：" :label-width="formLabelWidth">
                 <el-input  v-model="goods.category" disabled="disabled" ></el-input>
              </el-form-item>
              </el-col>
              <el-col :span="12">
               <el-form-item label="货物数量：" :label-width="formLabelWidth">
               <el-input v-model="goods.number" autocomplete="off"  value="number" disabled="disabled"></el-input>
            </el-form-item>
               </el-col>

                <el-col :span="12">
               <el-form-item  @click.native="Time"  label="入库时间：" :label-width="formLabelWidth">
                          <el-input v-model ="goods.warehouseEntryTime"  disabled="disabled"></el-input>
                    </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="入库温度：" :label-width="formLabelWidth">
                 <el-input v-model="goods.temperature" autocomplete="off"  value="number" disabled="disabled"></el-input>
              </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="货物过期时间：" :label-width="formLabelWidth">
                   <el-input  v-model ="goods.comGoBad" autocomplete="off"  value="number" disabled="disabled"></el-input>
              </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="租借到期时间：" :label-width="formLabelWidth">
              <el-input  v-model ="goods.deadlineTime" autocomplete="off"  value="number" disabled="disabled"></el-input>
              </el-form-item>
              </el-col>
               <el-col :span=12>
                    <el-form-item label="库区：" style="margin-left:70px">
                      <el-input  v-model="goods.locationId" disabled="disabled" style="width:200px"></el-input>
                    </el-form-item>
                </el-col>
              <el-col :span="12">
              <el-form-item label="入库员: " :label-width="formLabelWidth" >
                    <el-input  v-model="goods.inuserName" disabled="disabled"></el-input>
               </el-form-item>
              </el-col>
                 <el-col :span="12">
                <el-form-item label="入库核验员: " @click.native="user" :label-width="formLabelWidth" >
                    <el-input  v-model="inCheckUserName" disabled="disabled"></el-input>
               </el-form-item>
                 </el-col>
      </el-form>

          <div slot="footer" class="dialog-footer">
              <el-button @click="dialogFormVisible = false">取 消</el-button>
               <el-button type="primary" @click="submit()">确 定</el-button>
           </div>
           </el-dialog>
  <!-- 分页器 -->
        <div class="block" style="margin-top:15px;">
            <el-pagination
            @size-change="handleSizeChange"
             @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[10,20,30,40]"
              :page-size="pageSize"
               layout="total, sizes, prev, pager, next, jumper"
                :total="tableData.length">
            </el-pagination>
  </div>
  </div>
</div>
</template>

<script>
import axios from '../../../axios'
export default {
  name: 'totalCheck',
  data () {
    return {
      userName: localStorage.currentUser_name,
      tableData: [
      ],
      goods: [
      ],
      currentPage: 1, // 当前页码
      total: 0, // 总条数
      pageSize: 10, // 每页的数据条数
      goodsId: '',
      inCheckUserName: '',
      employees_name: '',
      dialogFormVisible: false,
      formLabelWidth: '120px'
    }
  },
  methods: {
    see (row) {
      this.dialogFormVisible = !this.dialogFormVisible
      this.goodsId = row.goods_id,
      this.id = row.id
      console.log(this.goodsId)
      console.log(row)
      // var goodsid =this.$route.params.goodsId;
      // var employee_name = this.$route.params.employees_name;
      // var id1=this.$route.params.id;
      // console.log(id1);
      // this.id=id1,
      // this.goods.employees_name=employee_name
      // console.log(employee_name);
      // this.goodsId=goodsid,
      axios({
        url: '/dp/queryGoodsById',
        method: 'GET',
        params: {
          goodsId: this.goodsId
        }
      }).then(res => {
        console.log(res)
        this.goods = res.data.data
      })
    },
    user () {
      this.inCheckUserName = this.userName
      console.log(this.inCheckUserName)
      return this.inCheckUserName
    },
    getTime () {
      var date = new Date()
      var seperator1 = '-'
      var seperator2 = ':'
      // 以下代码依次是获取当前时间的年月日时分秒
      var year = date.getFullYear()
      var month = date.getMonth() + 1
      var strDate = date.getDate()
      var minute = date.getMinutes()
      var hour = date.getHours()
      var second = date.getSeconds()
      // 固定时间格式
      if (month >= 1 && month <= 9) {
        month = '0' + month
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = '0' + strDate
      }
      if (hour >= 0 && hour <= 9) {
        hour = '0' + hour
      }
      if (minute >= 0 && minute <= 9) {
        minute = '0' + minute
      }
      if (second >= 0 && second <= 9) {
        second = '0' + second
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate +
      					' ' + hour + seperator2 + minute + seperator2 + second
	  return currentdate
    },
    Time () {
      this.getTime()
      this.goods.warehouseEntryTime = this.getTime()
    },
    // this.goodsId =row.goods_id,
    // this.employees_name=row.employees_name
    // console.log(this.employees_name);
    // this.id=row.id;
    /*      this.$router.push({name:'nextInput',
               params:{name:this.customer.name, contact:this.customer.contact}}); */
    // this.$router.push({name:"inputCheck", params:{goodsId:this.goodsId,id:this.id,employees_name:this.employees_name}},)
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
      this.currentPage = 1
      this.pageSize = val
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val
    },
    submit () {
      this.dialogVisible = !this.dialogVisible,
      console.log(this.goods)
      console.log(this.goodsId)
      console.log(this.id)
      axios({
        url: '/dp/in-check/submitInCheck',
        method: 'GET',
        params: {
          goodsId: this.goodsId,
          id: this.id
        }
      }).then(res => {
        console.log(res)
      })
    }

  },
  created () {
    // 页面刷新时重置搜索框和按键状态
    axios({
      url: '/dp/in-check/query',
      method: 'get'
    }).then(res => {
      console.log(res)
      this.tableData = res.data.data
      this.page.total = parseInt(res.data.data.total)
      console.log(this.page.total)
    }).catch(err => {
      //             console.log(err.response)
      this.$alert(err.response.data.msg, '请联系管理员', {
        confirmButtonText: '确定',
        callback: action => {
        }
      })
    })
  }
}
</script>
<style lang='less' scoped>
/deep/.cell
{
  font-weight: bold;
  font-size: 20px;
  color: rgb(61, 59, 59);
}

 .total{
 width: 1200px;
    margin: 0 auto;
    display: flex;
    position: relative;
    height: 670px;

.box{
  width: 1120px;
  height: 600px;
  margin: 50px 60px ;

 /deep/.block{
     .el-pagination{
  .el-pagination__total{
  font-weight: bold;
  font-size: 20px;
  color: rgb(61, 59, 59);
}
.el-pager
.number{
  font-weight: bold;
  font-size: 20px;

}
.el-pagination__jump{
  font-weight: bold;
  font-size: 20px;
  color:rgb(61, 59, 59);
}
.el-input__inner{
  font-weight: bold;
  font-size: 20px;
  color: rgb(61, 59, 59);
}
  }
  }

.button{
  font-weight: bold;
  font-size: 20px;
  color:rgb(61, 59, 59);
}

}
}

</style>
